/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package chatsoft.server.buz;

import ChatSoft.model.ChatMessage;
import ChatSoft.model.User;
import ChatSoft.model.UserData;
import ChatSoft.model.VoiceRequestMessage;
import ChatSoft.model.VoiceResponseMessage;
import ChatSoft.model.buz.SendObject;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;

/**
 *
 * @author VinhThien
 */
public class VoiceController extends Thread {

    public String navigate;
    public BufferedInputStream inStream;
    public Object recieveObject = null;
    SendObject sendObject;
    private String UserName;

    public VoiceController(BufferedInputStream input, String navi) {
        inStream = input;
        navigate = navi;
    }

    @Override
    public void run() {
        byte tempBuffer[] = new byte[10000];
        try {
            while (inStream.read(tempBuffer) != -1) {
                BufferedOutputStream outStream = ServerStaticVariable.voiceOnlineStream.get(navigate);
                if (outStream != null)
                    outStream.write(tempBuffer, 0, 10000);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
